package cn.chinaunicom.admin.controller;

import java.util.Objects;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.easy.secret.config.SecureProperties;

import cn.chinaunicom.admin.service.IDigitalEnvelopService;
import cn.chinaunicom.fast.common.exception.ServiceException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @ProjectName: esay-secret-server
 * @Package: cn.chinaunicom.admin.controller
 * @ClassName: AysnKeyController
 * @Description: java类作用描述
 * @Author: wangjc
 * @CreateDate: 2023/11/20
 * @UpdateUser: wangjc
 * @UpdateDate: 2023/11/20
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
@RestController
@Slf4j
@Data
@RequestMapping("/easy")
public class AysnKeyController {

    @Autowired
    private SecureProperties properties;

    @Autowired
    private IDigitalEnvelopService deService;

    /**
     * 获取数字信封中得密钥信息
     *
     * @param accessToken   通行令牌
     * @param compartId     分仓id
     * @return
     */
    @GetMapping("get")
    public String getKey(String accessToken, String compartId) {
        if(Objects.isNull(accessToken) || Objects.isNull(compartId)) {
            throw new ServiceException("600","入参不能为空");
        }

        return this.deService.getKeyToHexString(compartId);
    }
}
